<?php
/* 
 *  获取简历完整读接口
 *  edit by gemj
 */
define('PRODUCTION_ROOT', dirname(dirname(dirname(dirname(__FILE__)))));

//应用配置
define('APP_NAME', 'Resume'); // 配置是哪个实例
define('APP_PATH', PRODUCTION_ROOT . '/App/' . APP_NAME); // 配置实例的APP路径


$myResumeConfig = include (PRODUCTION_ROOT . '/App/Resume/Config/MyResume.php');
$showhide = $myResumeConfig['areaInfo'];
require_once PRODUCTION_ROOT . '/Config/config.php';
require_once PRODUCTION_ROOT . '/Libs/UcUser.php';

$uid = (int)$_GET['uid'];
if( $uid <= 0 ){
	echo "0";
	exit();
}

$con = mysql_connect(DB_HOST, DB_USER, DB_PSSSWORD);
if( !$con ){
	echo "0";
	exit();
}

$db_relation_arr = array(
		"base"	=> "resume_baseInfo:uid",
		"edu"	=> "resume_edu:uid",
		"lang"	=> "resume_language:userid",
		"project"=>"resume_project:userid",
		"practice"=>"resume_job:userid",
		"offer" => "resume_jobhistory:userid",
		"cert"	=> "resume_cert:userid",
		"training"=>"resume_train:userid",
		"position"=>"resume_position:uid",
		"it"	=> "resume_it:userid",
		"schoolaward"=>"resume_reward:uid",
		"other"	=> "resume_other:uid"
		);

$db_selected = mysql_select_db(DB_NAME, $con);
$sql = "SELECT * from resume_areapos WHERE uid=" . $uid;
$result = mysql_query($sql, $con);
$info = mysql_fetch_array($result);
$score = 0;
if( !empty($info) && is_array($info) ){
	unset($info['uid']);
	foreach( $info as $key => $val ){
		$table_info = !empty($db_relation_arr[$key]) ? $db_relation_arr[$key] : '';
		if(!empty($table_info)){
			$table_arr = explode(":",$table_info); 
			$table_name = $table_arr[0];
			$uid_filed = $table_arr[1];
			$search_sql = "Select 1 from `$table_name` where $uid_filed=".$uid;
			$uid_re = mysql_query($search_sql,$con);
			$uid_info = mysql_fetch_array($uid_re);
			if(!empty($uid_info)){
				if( !empty($showhide[$key]) ){
					$score += $showhide[$key]['score'];
				}
			}
		}
		if($key == 'photo'){
                        $photo = Libs_UcUser::checkAvatar($uid);
                        if($photo == 1){
                                $score += $showhide[$key]['score'];
                        }
                }
	}
}
echo $score;

?>
